TvExtender

Helper class to add Android TV extensions to notifications.

To create a notification with a TV extension:

  1. Create an NotificationCompat.Builder, setting any desired properties.
  2. Create a TvExtender.
  3. Set TV-specific properties using the set methods of TvExtender.
  4. Call extend to apply the extension to a notification.
Notification notification = new NotificationCompat.Builder(context)
        ...
        .extend(new TvExtender()
                .setChannelId("channel id"))
        .build();
NotificationManagerCompat.from(mContext).notify(0, notification);

TV extensions can be accessed on an existing notification by using the TvExtender(Notification) constructor, and then using the get methods to access values.

Note that prior to O this field has no effect.

Constructors

Link copied to clipboard
constructor()
Create a TvExtender with default options.
constructor(@NonNull notif: @NonNull Notification)
Create a TvExtender from the TvExtender options of an existing Notification.

Functions

Link copied to clipboard
open fun extend(builder: @NonNull NotificationCompat.Builder): @NonNull NotificationCompat.Builder
Apply a TV extension to a notification that is being built.
Link copied to clipboard
@Nullable
open fun getChannelId(): @Nullable String
Returns the id of the channel this notification posts to on TV.
Link copied to clipboard
@Nullable
open fun getContentIntent(): @Nullable PendingIntent
Returns the TV-specific content intent.
Link copied to clipboard
@Nullable
open fun getDeleteIntent(): @Nullable PendingIntent
Returns the TV-specific delete intent.
Link copied to clipboard
Returns true if this notification should be shown on TV.
Link copied to clipboard
Returns true if this notification should not show messages over top of apps outside of the launcher.
Link copied to clipboard
@NonNull
open fun setChannelId(@Nullable channelId: @Nullable String): @NonNull NotificationCompat.TvExtender
Specifies the channel the notification should be delivered on when shown on TV.
Link copied to clipboard
@NonNull
open fun setContentIntent(@Nullable intent: @Nullable PendingIntent): @NonNull NotificationCompat.TvExtender
Supplies a PendingIntent to be sent when the notification is selected on TV.
Link copied to clipboard
@NonNull
open fun setDeleteIntent(@Nullable intent: @Nullable PendingIntent): @NonNull NotificationCompat.TvExtender
Supplies a PendingIntent to send when the notification is cleared explicitly by the user on TV.
Link copied to clipboard
@NonNull
open fun setSuppressShowOverApps(suppress: Boolean): @NonNull NotificationCompat.TvExtender
Specifies whether this notification should suppress showing a message over top of apps outside of the launcher.